var app = getApp(),
  $ = require("../../utils/httpHelper.js");
var address = require('../../utils/city.js')

Page({
  data: {
    username: '',
    phone: '',
    yzm: '',
    shenfencodestr: "",
    height: 0,
    shenfenjc: false,
    shenfencode: false,
    yzmjc: false,
    yzmstatus: false
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({ height: res.windowHeight })
      }
    })
    let par = {
      rd_session: app.globalData.userInfo.rd_session
    }
    // $.httpPost("member_info", par, (data, err) => {
    //   this.setData({
    //     username: data.data.data.name,
    //     shenfencodestr: data.data.data.idcard,
    //     phone: data.data.data.phone
    //   })
    // })

  },



  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  inputuser(e) {
    this.setData({
      username: e.detail.value
    })
  },
  inputshenfen(e) {
    this.setData({
      shenfencodestr: e.detail.value
    })
  },
  inputphone(e) {
    this.setData({
      phone: e.detail.value
    })
  },
  checkinfo() {
    let name = this.data.username
    let phone = this.data.phone
    let shenfencodestr = this.data.shenfencodestr
    if (app.check_empty(name) || app.check_empty(phone) || app.check_empty(shenfencodestr)) {
      return false
    } else {
      return true
    }
  },
  tj() {
    if (this.checkinfo()) {
      if (app.checkPhone(this.data.phone)){
        let par = {
          rd_session: app.globalData.userInfo.rd_session,
          name: this.data.username,
          phone: this.data.phone,
          idcard: this.data.shenfencodestr
        }
        $.httpPost("apply_agent", par, (data, err) => {
          if (data.result == "success") {
            wx.switchTab({
              url: '/pages/mine/mine',
            })
          }
        })
      }else{
        wx.showToast({
          title: '手机格式不对',
        })
      }
    } else {
      wx.showToast({
        title: '不能是空',
      })
    }
  },
 

})
